<?php
/*
 *============================================================================
 * Cornice PHP Framework & Website Builder
 * Freeware (f) 2011 by Inforo Software & Computer
 *============================================================================
 * Captcha image of 6 digits
 */

//header & get module name
header("Content-type: image/gif");
$query_string = $_SERVER["QUERY_STRING"];
parse_str($query_string); //?module=*

//session stuffs
ini_set("session.cookie_path","/");
session_name($module."_sid"); 
session_start();

//background
$image = imagecreatetruecolor(50,20);
$background = imagecolorallocate($image, 255,255,255);
$color = imagecolorallocate($image, 0,0,255);
imagefill($image,0,0,$background);

//generate a number
$random_number = rand(100000,999999);
$captcha = strval($random_number); 
$_SESSION["captcha"] = $captcha;

//draw the number
imagestring($image,3, 0,2, $captcha,$color);
imagegif($image);
imagedestroy($image);